from flask import Blueprint, request, jsonify
from utils.utils import build_fail_response, confirm_params_type
from database.db_tools import SQLServerDatabase, connection_string

# 创建蓝图
ts_recheck_config_page = Blueprint('ts_recheck_config_page', __name__)




# 查询配置表信息
@ts_recheck_config_page.route('/pyapi/getTsRecheckAttrConfig', methods=['GET'])
def getTsRecheckAttrConfig():
    try:
        # 操作数据库
        with SQLServerDatabase(connection_string) as db:
            # 无需分页，查询全部
            res = db.execute_query_all("ts_recheck_config")
            return jsonify(res)
            # if res['code'] == 200:
            #     data = res['data']
            #     return build_response(data, message="成功")
            # else:
            #     return build_response([], message="失败", code=FAILURE)
    except Exception as e:
        return build_fail_response(message=str(e), params=confirm_params_type(request))


